<template>
  <el-container class="home-container">
    <el-header class="home-header">
      <span class="home_title">麒麟企业快速开发平台</span>
      <el-dropdown  @command="handleCommand">
        <span>{{this.$store.state.user.username}}</span>
        <i class="el-icon-setting" style="margin-right: 15px"></i>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>查看</el-dropdown-item>
          <el-dropdown-item>新增</el-dropdown-item>
          <el-dropdown-item command="logout">注销</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </el-header>
    <el-container>
      <el-aside width="200px" class="home-aside">
        <el-menu :default-openeds="['1', '3']" router >
          <el-submenu index="1"  v-for="item in this.routers">
            <template slot="title">
              <i class="el-icon-message"></i>{{item.name}}
            </template>
            <el-menu-item-group>
              <el-menu-item :index="chiled.path"  v-for="chiled in item.children">{{chiled.name}}</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-main>
        <el-breadcrumb separator=">">
          <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item></el-breadcrumb-item>
        </el-breadcrumb>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
export default {
  data() {
    return {};
  },methods:{
    handleCommand(command){
      if(command && command=='logout'){
         console.log("----------------");
        localStorage.removeItem("user");
        this.$router.replace({path:"/"});
      }
    }
    },
  computed:{
      routers(){
          return this.$router.options.routes[1].children
      }
  },mounted(){
    console.log("==========================")
    console.log(this.$router.options.routes[1].children);

  }
  
};
</script>

<style>
.home-container {
  height: 100%;
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100%;
}
.home-header {
  background-color: #20a0ff;
  color: #333;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: content-box;
  padding: 0px;
}
.home_title {
  color: #fff;
  font-size: 22px;
  display: inline;
  margin-left: 8px;
}
.home-aside {
  background-color: #ececec;
}
</style>